#pragma once
#include <cstdint>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <net/if.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <linux/can.h>
#include <linux/can/raw.h>
#include <thread>
#include <functional>
#include <vector>
#include <string>
#include <memory>
#include <iostream>
namespace can
{
class CanAgent
{
public:
	virtual bool is_connected() = 0;
	virtual void start_asyn_read() = 0;
	virtual void register_asyn_read_cb(std::function<void(can_frame &frame)> fun) = 0;
	virtual bool write_frame(can_frame &frame) = 0;

private:
	virtual void asyn_read() = 0;
	const std::string can_name_;
	int socket_;
	bool connected_;
	long timeout_;
	std::shared_ptr<std::thread> t_ptr_;
	std::vector<std::function<void(can_frame &frame)>> cb_fun_vector_;
};
} // namespace can
